package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.constant.CommonConstant;
import com.hl.sfzy.entity.SysReply;
import com.hl.sfzy.mapper.SysReplyMapper;
import com.hl.sfzy.service.SysReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ffc
 * @version 1.0
 * @description: TODO
 * @className: SysReplyServiceImpl
 * @date 2024/7/12 16:59
 */

@Service("sysReplyService")
public class SysReplyServiceImpl implements SysReplyService {

    @Autowired
    private SysReplyMapper sysReplyMapper;


    @Override
    public int add(SysReply entity) {
        return sysReplyMapper.insert(entity);
    }

    @Override
    public int edit(SysReply entity) {
        return sysReplyMapper.update(entity);
    }

    @Override
    public int remove(Integer id) {
        return sysReplyMapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return sysReplyMapper.deleteBatch(ids);
    }

    @Override
    public List<SysReply> find(SysReply entity) {
        return sysReplyMapper.select(entity);
    }

    @Override
    public SysReply findById(Integer id) {
        SysReply sysReply = sysReplyMapper.selectById(id);
        return sysReply;
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, SysReply entity) {
        PageHelper.startPage(pageNum,pageSize);
        List<SysReply> list = sysReplyMapper.select(entity);
        PageInfo<SysReply> pageInfo = new PageInfo<>(list);
        Map<String,Object> map = new HashMap<>();
        map.put(CommonConstant.PAGE_LIST,list);
        map.put(CommonConstant.TOTAL,pageInfo.getTotal());
        map.put(CommonConstant.PAGE_TOTAL,pageInfo.getPages());
        return map;
    }
}
